package com.ran.java_gobang_new.controller;

import com.ran.java_gobang_new.pojo.request.UserInfoLoginRequest;
import com.ran.java_gobang_new.pojo.request.UserInfoRegisterRequest;
import com.ran.java_gobang_new.pojo.response.UserInfoRegisterResponse;
import com.ran.java_gobang_new.service.UserInfoServise;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ran
 * Date: 2025-09-02
 * Time: 22:43
 */
@RestController
@RequestMapping("/user")
public class UserInfoController {
    @Autowired
    private UserInfoServise userInfoServise;

    // 登录
    @RequestMapping("/login")
    public Object login(@Validated UserInfoLoginRequest userInfoLogin, HttpServletRequest request) {
        return userInfoServise.login(userInfoLogin,request);
    }

    // 登陆成功后, 进入游戏大厅, 获取玩家信息
    @RequestMapping("/getUserInfo")
    public Object getUserInfo(HttpServletRequest request) {
        return userInfoServise.getUserInfo(request);
    }

    @RequestMapping("/register")
    public UserInfoRegisterResponse register(@Validated UserInfoRegisterRequest request) {
        return userInfoServise.register(request);
    }
}
